<script>
function failure(message){
	//alert(message);
	box_failure = new LightFace({ 
			title: 'Failure', 
			width : 300,
			content: "<div class='failure'>"+message+"</div>"
			,
			buttons: [{ title: 'Cancel', event: function() { this.close();}, color: 'green'}]
		});
		box_failure.open();
}
//---------------------------------------------------------------------------------------------------->>>> album
function showImages(){
	var myRequest = new Request({
		url: '<?php echo site_url(array("project","showImages",$this->uri->segment(3,0)))?>',
		method: 'post',
		onSuccess : function(responseText){
			$('showImages').innerHTML = responseText;
		}
	}).send();
}
//---------------------------------------------------------------------------------------------------->>>> images
function addImagesTrue1() {
	var addImages = new Request({
		url: '<?php echo site_url(array("project","addImagesTrue",$this->uri->segment(3,0)))?>',
		method: 'post',
		onSuccess : function(responseText){
			$('addImagesTrue').innerHTML = responseText;
		}
	})

	addImages.send();
//	addImages.fade('in');
//	addImages.fade(5000);
}

function saveImages1(form, evt){
	alert(document.getElementById('images').value);
	alert(document.getElementById('tag').value);
	alert($(document.forms['formImages']).images.value);
	new Event(evt).stop();
	form = $(form);
		form.set('send', {url:'<?php echo site_url('project/saveImages')?>',method :'post',
			data: { 
				images : $(document.forms['formImages']).images.value,
				tag : $(document.forms['formImages']).tag.value,
			},
		 	onSuccess: function(responseText, responseXML){
//				box_images.close();
				addImages.close();
				showImages();
			},
			onComplete: function(){
				
			},
			onFailure: function(xhr){
				failure();
			}
		});
		form.send();
	
	return false;
}
function saveImages(form, evt){
//	alert(document.getElementById('images').value);
//	alert(document.getElementById('tag').value);`
//	alert($(document.forms['formImages']).images.value);
	new Event(evt).stop();
	form = $(form);
		form.set('send', {url:'<?php echo site_url('project/saveImages')?>',method :'post',
			data: { 
				images : $(document.forms['formImages']).images.value,
				tag : $(document.forms['formImages']).tag.value,
			},
		 	onSuccess: function(responseText, responseXML){
				box_images.close();
				showImages();
			},
			onComplete: function(){
				
			},
			onFailure: function(xhr){
				failure();
			}
		});
		form.send();
	
	return false;
}
function addImagesTrue(){
	box_images = new LightFace.Request({
		width:400,
		height:210,
		url: '<?php echo site_url(array("project","addImagesTrue1",$this->uri->segment(3,0)))?>',
		buttons: [
			{ title: 'Save', event: function() { saveImages(this, event); }, color: 'blue' },
			{ title: 'Cancel', event: function() { this.close(); } }
		],
		title: 'Add Images',
		
		onSuccess:function(){
			new FancyUpload3.Attach(
					'fcUpload-list', 
					'fcUpload-attach, fcUpload-attach-2',
					{path:'<?php echo site_url(array('js','Swiff.Uploader.swf'))?>',
					 imageUrl:'<?php echo site_url(array('images','FancyUpload'))?>',
					 url:'<?php echo site_url(array('js','Swiff.Uploader.php'))?>',
					 verbose:true});
		},
		onComplete:function(){
			new FancyUpload3.Attach(
					'fcUpload-list', 
					'fcUpload-attach, fcUpload-attach-2',
					{path:'<?php echo site_url(array('js','Swiff.Uploader.swf'))?>',
					 imageUrl:'<?php echo site_url(array('images','FancyUpload'))?>',
					 url:'<?php echo site_url(array('js','Swiff.Uploader.php'))?>',
					 verbose:true});
		}
	}).open();
}
//---------------------------------------------------------------------------------------------------->>>> show comment album
function showCommentAlbum(){
	var myRequest = new Request({
		url: '<?php echo site_url(array("project","showCommentAlbum",$this->uri->segment(3,0)))?>',
		method: 'post',
		onSuccess : function(responseText){
			$('showCommentAlbum').innerHTML = responseText;
		}
	}).send();
}
//---------------------------------------------------------------------------------------------------->>>> edit
function editAlbum() {
	box_editAlbum = new LightFace.Request({
		width:400,
		height:160,
		url: '<?php echo site_url(array("project","addEditAlbum",$this->uri->segment(3,0)))?>',
		buttons: [
			{ title: 'Save', event: function() { saveEditAlbum(this, event); }, color: 'blue' },
			{ title: 'Cancel', event: function() { this.close(); } }
		],
		title: 'Edit Album'
	}).open();
}
function saveEditAlbum(form, evt) {
	new Event(evt).stop();
	form = $(form);
		form.set('send', {url:'<?php echo site_url(array('project','saveEditAlbum',$this->uri->segment(3,0)))?>',method :'post',
		 	onSuccess: function(responseText, responseXML){
				box_editAlbum.close();
				showCommentAlbum();
//				$('commentAlbum').set('value','');
			},
			onComplete: function(){
				
			},
			onFailure: function(xhr){
				failure();
			}
		});
		form.send();
	
	return false;
}
//---------------------------------------------------------------------------------------------------->>>> save

function saveCommentAlbum(form, evt) {
	new Event(evt).stop();
	form = $(form);
		form.set('send', {url:'<?php echo site_url(array('project','saveCommentAlbum',$this->uri->segment(3,0)))?>',method :'post',
		 	onSuccess: function(responseText, responseXML){
				//box_images.close();
				showCommentAlbum();
				$('commentAlbum').set('value','');
			},
			onComplete: function(){
				
			},
			onFailure: function(xhr){
				failure();
			}
		});
		form.send();
	
	return false;
}
//---------------------------------------------------------------------------------------------------->>>> delete
function removeAlbum(){
	box_deleteAlbum.close();
	var myRequest = new Request({
		url: '<?php echo site_url(array("project","deleteAlbum",$this->uri->segment(3,0)))?>',
		method: 'post',
		onSuccess : function(responseText){
			//$('showImages').innerHTML = responseText;
			//window.location = "<?php echo site_url(array("project"))?>";
		}
	}).send();
}
function deleteAlbum(){
	box_deleteAlbum = new LightFace({
		buttons: [
			{ title: 'Delete', event: function() { removeAlbum(this, event); }, color: 'green' },
			{ title: 'Cancel', event: function() { this.close(); } }
		],
		title: 'Confirmation',
		content : 'Do you sure to delet this album....!',
		
	}).open();
}
//---------------------------------------------------------------------------------------------------->>>> formcheck
window.addEvent('domready',function(){
	showImages();
	showCommentAlbum();
	new FormCheck('formCommentAlbum', {
		display : {
			errorsLocation : 1,
			showErrors : 1,
			addClassErrorToField : 1
		}
	});
});
</script>
<script type="text/javascript">
//	window.addEvent('domready', function () {
//		new FancyUpload3.Attach(
//				'fcUpload-list', 
//				'fcUpload-attach, fcUpload-attach-2',
//				{path:'<?php echo site_url(array('js','Swiff.Uploader.swf'))?>',
//				 imageUrl:'<?php echo site_url(array('images','FancyUpload'))?>',
//				 url:'',
//				 verbose:true});
//	});
</script>
 	
<table bgcolor="#CCCCCC" width="755" border="0" cellspacing="1" cellpadding="0">
  <tr>
    <td align="center"><table bgcolor="#F8F8F8" height="300" width="100%" border="0" cellspacing="5" cellpadding="10">
      <tr>
        <td valign="top" colspan="2">
        <div align="right">
        <a class="uiButton uiAdd" href="<?php echo site_url(array('project','addImagesTrue',$this->uri->segment(3,0)))?>">Add Images</a>
        </div>        
        </td>
      </tr>
      <tr valign="top">
       <td colspan="2">
       	  <table align="center" border="0" cellpadding="3" cellspacing="2">
       	   <tbody id="addImagesTrue"></tbody>
       	  </table>
       	  <table border="0" cellpadding="3" cellspacing="2" id="project" >
     	  <tbody class="link" id="showImages"></tbody>
          </table>
          <div align="right">
        <a class="uiButton uiAdd" href="<?php echo site_url(array('project','addImagesTrue',$this->uri->segment(3,0)))?>">Add Images</a>
        </div>  
       </td>
      </tr>
      <tr valign="top">
        <td width="150" align="right">
          <a class="uiButton uiAdd" href="javascript: editAlbum()" >Edit Album</a>
		  <a class="uiButton uiAdd" href="javascript: deleteAlbum()" >Delete This ALbum</a>
        </td>
      	<td bgcolor="#F4F4F4">
         <table width="100%" border="0" cellpadding="5" cellspacing="0">
     	  <tbody id="showCommentAlbum"></tbody>
         </table>
         <div align="left">
         	  <form id="formCommentAlbum" name="formCommentAlbum" method="post" onsubmit="saveCommentAlbum(this, event)" enctype="multipart/form-data">
               <textarea class="validate['required']" name="commentAlbum" id="commentAlbum" cols="65" rows="3"></textarea>
               <div align="right">
                <input type="submit" class="uiButton uiSave" name="button" id="button" value="Share"/>
               </div>
             </form>
         </div>
      	</td>
      </tr>
    </table></td>
  </tr>
</table>